﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RedBlueBalls
{
    class RedSegment
    {
        private static bool analyzed = false;
        private static bool checkBest = false;

        public static void analyze(RedBlueBallRecord[] records)
        {
            if (checkBest)
            {
                foreach (RedBlueBallRecord record in records)
                {
                    Tracer.AppendMessage(ConvertToString(record.GetSegments()));
                }
                    
            }

            analyzed = true;
        }

        public static bool predict(RedBlueBallRecord candidate)
        {
            if (!analyzed)
            {
                Tracer.AppendMessage("Please analyze the data first!");
                return false;
            }

            return true;
        }

        private static String ConvertToString(int[] segments)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < segments.Length; i++)
            {
                if (i > 0)
                    sb.Append(", ");
                sb.Append("Seg ").Append(i + 1).Append(": ");
                sb.Append(segments[i]);
            }

            return sb.ToString();
        }
    }
}
